<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<head>
    <%@ include file="../../include/import.inc" %>
</head>
<body>
<%@ include file="../../include/title.inc" %>
<div>
    <div class="Head_oper">
        <div class="FL" id="head_oper">
            当前位置： > > <span class="blue"></span>
        </div>
        <div class="FR" id="buttons">
            <a href="javascript:query()" class="Bu1 Bu1_green"><b><i class="icon i_Inquiry_2"></i>查询</b></a>
            <a href="javascript:resetQuery()" class="Bu1"><b><i class="icon i_Reset_2"></i>重置</b></a>
        </div>
        <div class="Clear"></div>
    </div>
</div>

<div class="WrapMiddle">
    <form id="form1" class="pageForm" method="post" action="<c:url value="/${apiUrl}/index"/>">
        <div class="ShrinkObj"><h2 class="Shrink_T Shrink_T_show">查询条件</h2>
            <div class="Shrink_G">
                <div class="queryCondition queryCondition2 PAD1">
${queryCondition}
                    <div class="query-item">
                        <div class="query-label">%s：</div>
                        <div class="query-content">
                            <zbiti:dictSelect code="%s" name="%s" value="${params.%s}"></zbiti:dictSelect>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="grid">
            <div style="float: left; padding-top: 4px; width: 400px; height: 30px">
                <a href='javascript:$.zbiti.popup("添加","<c:url value='/${apiUrl}/add'/>", 1000, 600)'
                   class="Bu1  Bu1_green ">
                    <b><i class="icon i_New_2"></i>添加</b>
                </a>
                <a href="javascript:void(0);" onclick="deletes()" class="Bu1 Bu1_4words">
                    <b><i class="icon i_Delete_2"></i>批量删除</b>
                </a>
            </div>
            <zbiti:page page="${ro.page}" export="false" template="">
                <table id="tab1" class="gridView table-fixed">
                    <thead class="tableHeader-processed">
                    <tr>
                        <th style="width:50px">
                            <input type="checkbox" name="op_all"
                                   onclick="$('#tab1 input[name=\'op\']').prop('checked', this.checked)"/>
                        </th>
                        <th style="width: 120px">操作</th>
${fieldNames}
                    </tr>
                    </thead>
                    <tbody>
                    <c:forEach items="${ro.page.resultList}" var="data" varStatus="row">
                        <tr>
                            <td nowrap="nowrap" style="text-align: center">
                                <input type="checkbox" value="${data.${idName}}" name="op"/>
                            </td>
                            <td nowrap="nowrap" class="oper">
                                <a href='javascript:$.zbiti.popup("修改","<c:url value='/${apiUrl}/edit/${data.${idName}}'/>", 1000, 600)'>修改</a>
                                <a href="javascript:void(0);" onclick="deletes('${data.${idName}}')">删除</a>
                            </td>
${fieldValues}
                        </tr>
                    </c:forEach>
                    </tbody>
                </table>
            </zbiti:page>
        </div>
    </form>
</div>
<%@ include file="../../include/foot.inc" %>
</body>
<script type="text/javascript">
    function query() {
        $("#form1").submit();
    }

    function deletes(id) {
        var idList = id || $('#tab1 input[name="op"]:checked').map(function () {
            return $(this).val();
        }).get().join(",");
        if (idList == null || idList.toString().length == 0) {
            $.zbiti.alert("请选择要删除的记录")
            return
        }

        if (confirm("确定删除吗")) {
            $.zbiti.post("/${apiUrl}/delete", {idList}, function (res) {
                $.zbiti.alert(res.message);
                if (res.success) {
                    query();
                }
            });
        }
    }
</script>